import React, { Fragment, useContext } from 'react';
import { Space, Button } from 'antd';

import '../common/style.less';
import { NeedUpdateContext } from '../common/NeedContext';

import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
import { JZLZ_STATE, ZRBGH_STATE, JHXD_STATE, XQZF_STATE } from '../common/Format';
import { NeedUpdateAPI } from '../common/type';

/**
 * @UpdateNeedFold 新增编辑卡片-右上角-按钮组件
 * @param openModal 打开物料弹窗
 * @returns
 */
const UpdateNeedFold: React.FC<NeedUpdateAPI.IUpdateNeedFold> = ({ openModal, onExport, curRes }) => {
  const { prefixCls, needInfo } = useContext(NeedUpdateContext);

  return (
    <Space>
      <Fragment>
        {needInfo?.id &&
          (needInfo?.state == JZLZ_STATE() || needInfo?.state == ZRBGH_STATE() || needInfo?.state == JHXD_STATE() || needInfo?.state == XQZF_STATE()) &&
          curRes?.['/purchaseNeedController/export'] && (
            <Button
              type={'primary'}
              size={'small'}
              // icon={<ExportOutlined />}
              className="manageBtntTxtStyle"
              onClick={onExport}
            >
              导出
            </Button>
          )}
        {/* {
          typeof needInfo?.id === 'undefined' && <Button
            type={'primary'}
            size={'small'}
            icon={<PlusOutlined className={`${prefixCls}conmpanyCardExtra`} />}
            className='manageBtntTxtStyle'
            onClick={() => {
              openModal(true);
            }}
          >
            选择
          </Button>
        } */}
      </Fragment>
    </Space>
  );
};
export default UpdateNeedFold;
